﻿using Md.Api.Model.Im.Request;
using Md.Im.Service;

namespace Md.Api.Service.Im;
/// <summary>
/// im发送消息服务
/// </summary>
public class ImSendService : ApiBase<RequestImSendModel>
{
    /// <summary>
    /// 执行
    /// </summary>
    protected override void ExecuteMethod()
    {
        if (Parameter.ClientId == null)
        {
            throw new AggregateException("客户端编号不能为空");
        }

        if (string.IsNullOrWhiteSpace(Parameter.ChannelName))
        {
            throw new AggregateException("频道名称不能为空");
        }

        if (Parameter.Message == null)
        {
            throw new AggregateException("消息体不能为空");
        }

        ImHelper.SendChanMessage(Parameter.ClientId.Value, Parameter.ChannelName, Parameter.Message);

        Result.Data = "发送成功";
    }
}
